import '../libs/mobiscroll/css/mobiscroll.min.css'
import '../libs/mobiscroll/js/mobiscroll.js'
import '../libs/mobiscroll/js/mobiscroll.select.js'
import '../libs/mobiscroll/js/mobiscroll.treelist.js'
import '../libs/mobiscroll/js/i18n/mobiscroll.i18n.zh.js'

var mobiscrollDate = {
    bind:function(){
        var self = this
        $(this.el).mobiscroll().date({
            theme:'mobiscroll',
            dateFormat: 'yy-mm-dd',
            mode:'scroller',
            lang: 'zh',
            maxDate:new Date(),
            display:'bottom'
        })
    },
    update:function(value){
        $(this.el).mobiscroll('setVal', value)
    }
}

var mobiscrollSelectBasic = {
    inserted:function(el){

        var names = [{
                text: "Abigail Hodges",
                value: 1
            }, {
                text: "Adam Robertson",
                value: 2
            }, {
                text: "Adrian Mackay",
                value: 3
            }, {
                text: "Adrian Springer",
                value: 4
            },
            // Showing partial data. Download full source
        ];
        var placeholder = $(el).data('placeholder')
        console.log(placeholder)
        // setTimeout(()=>{
            mobiscroll.select(`#${el.id}`,{
                data:names,
                lang: 'zh',
                display:'bottom',
                placeholder:'123',
                width:500,
            })
        // },300)
    },
    update:function(el,binding){
        // mobiscorll不会因为select的值改变而刷新mobiscorll生成的input的值，所以手动修改dom的value
        // $(el).prev().val(binding.value)
    }
}

var mobiscrollSelectGroup = {
    bind:function(){
        $(this.el).mobiscroll().select({
            theme:'mobiscroll',
            lang: 'zh',
            display: 'bottom',
            label: 'City',
            group: true,
            groupLabel: 'Province',
            fixedWidth: [100, 170]
        })
    },
    update:function(value){
        // mobiscorll不会因为select的值改变而刷新mobiscorll生成的input的值，所以手动修改dom的value
        $(this.el).prev().val(value)
    }
}

export { mobiscrollDate, mobiscrollSelectBasic, mobiscrollSelectGroup }

